<template>
  <el-card>
    <!-- 内容列表 -->
    <bread-crumb slot="header">
      <template slot="title">内容管理</template>
    </bread-crumb>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="新闻管理" name="first"></el-tab-pane>
      <el-tab-pane label="爆款包子" name="second"></el-tab-pane>
      <el-tab-pane label="包子&&其他" name="third"></el-tab-pane>
      <el-tab-pane label="banner" name="fourth"></el-tab-pane>
      <el-tab-pane label="门店" name="fifth"></el-tab-pane>
    </el-tabs>
    <component :is="show" />
  </el-card>
</template>

<script>
import { journalismSee } from "../../utils/api";
import NewsList from "../../components/common/news_list.vue";
import BaoziAndOther from "../../components/common/baozi_and_other.vue";
import HotBaoziList from "../../components/common/hot_baozi_list.vue";
import Banner from "../../components/common/banner.vue";
import Store from "../../components/common/store.vue";
export default {
  data() {
    return {
      show: "NewsList",
      activeName: "first",
      select: "",
      value1: "",
      defaultImg: require("../../assets/img/404.png"),
      formData: {
        // 文章状态查询数组
        status: 5,
        channel_id: null,
        data: []
      },
      page: {
        total: 0,
        currentPage: 1,
        pageSize: 10
      },
      params: {
        type: ""
      },
      news_list: []
    };
  },
  components: {
    NewsList,
    BaoziAndOther,
    HotBaoziList,
    Banner,
    Store
  },
  methods: {
    // 标签切换
    handleClick(tab, event) {
      // console.log(tab.index, event);
      if (tab.index === "0") {
        this.show = "NewsList";
      } else if (tab.index === "1") {
        this.show = "HotBaoziList";
      } else if (tab.index === "2") {
        this.show = "BaoziAndOther";
      } else if (tab.index === "3") {
        this.show = "Banner";
      } else if (tab.index === "4") {
        this.show = "Store";
      }
    },
    // 获取新闻
    getNews() {
      journalismSee(this.params).then(res => {
        // console.log(res);
        this.news_list = res.data.results;
        this.page.total = res.data.results.length;
      });
    },
    changePage(newPage) {
      // 分页时要携带条件
      this.page.currentPage = newPage;
    }
  },
  created() {
    this.getNews();
  }
};
</script>

<style lang="less" scoped>
.article-item {
  display: flex;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px slolid #f2f3f4;
  .left {
    display: flex;
    .info {
      display: flex;
      flex-direction: column;
      margin-left: 10px;
      justify-content: space-around;
    }
    img {
      width: 180px;
      height: 100px;
      border-radius: 10px;
    }
  }
  .right {
    display: flex;
    align-items: center;
  }
}
</style>
